let engines = [
  {
    engineId: 'sh-engine-440984947318784',
    name: '测试',
    createTime: '2024-06-27T18:32:17.482+08:00',
    updateTime: '2024-06-27T18:32:17.484+08:00',
    startTime: null,
    state: 0,
    endpoint: null,
    spec: {
      cpus: 0,
      memory: 0,
      enableGpu: 0,
    },
    image: 'registry.xuelangyun.com/shuzhi-amd64/vision-p2p-client:v17',
  },
  {
    engineId: 'sh-engine-440689965048831',
    name: 'test1',
    createTime: '2024-06-24T02:31:09.000+00:00',
    updateTime: '2024-06-24T02:31:10.915+00:00',
    startTime: '2024-06-24T02:31:09.000+000+00:00',
    state: 3,
    endpoint: '10.88.40.88:443/sh/engine/441334676780032/${serverPort}',
    spec: {
      cpus: 0,
      memory: 0,
      enableGpu: 0,
    },
    image: 'registry.xuelangyun.com / shuzhi / redis: 6.2.5 - alpine',
  },
  {
    engineId: 'sh-engine-440689965048832',
    name: 'test2',
    createTime: '2024-06-24T02:31:09.000+00:00',
    updateTime: '2024-06-24T02:31:10.915+00:00',
    startTime: '2024-06-24T02:31:09.000+000+00:00',
    state: 3,
    endpoint: '10.88.40.88:443/sh/engine/441334676780032/${serverPort}',

    spec: {
      cpus: 0,
      memory: 0,
      enableGpu: 0,
    },
    image: 'registry.xuelangyun.com / shuzhi / redis: 6.2.5 - alpine',
  },
  {
    engineId: 'sh-engine-440689965048833',
    name: 'test3',
    createTime: '2024-06-24T02:31:09.000+00:00',
    updateTime: '2024-06-24T02:31:10.915+00:00',
    startTime: '2024-06-24T02:31:09.000+000+00:00',
    state: 3,
    endpoint: '10.88.40.88:443/sh/engine/441334676780032/${serverPort}',

    spec: {
      cpus: 0,
      memory: 0,
      enableGpu: 0,
    },
    image: 'registry.xuelangyun.com / shuzhi / redis: 6.2.5 - alpine',
  },
];

let applyRes = {
  engineId: 'sh-engine-440689965048832',
  name: 'test',
  createTime: '2024-06 - 24T02: 31:09.000+00:00',
  updateTime: '2024-06 - 24T02: 31: 10.915+00:00',
  startTime: '2024-06 - 24T02: 31:09.000+000+00:060',
  state: 3,
  endpoint: '10.88.40.88:443/sh/engine/441334676780032/${serverPort}',

  spec: {
    cpus: 0,
    memory: 0,
    enableGpu: 0,
  },
  image: 'registry.xuelangyun.com / shuzhi / redis: 6.2.5 - alpine',
};

export default {
  'POST /api/v1/engine/list': (
    req: {
      body: {
        userId: string;
      };
    },
    res: any,
  ) => {
    res.json({
      success: true,
      code: 200,
      message: '获取引擎列表成功',
      data: engines,
      errorCode: 0,
    });
  },
  'POST /api/v1/engine/release': (
    req: {
      body: {
        userId: string;
        engineId: string;
      };
    },
    res: any,
  ) => {
    res.json({
      success: true,
      errorCode: 0,
      data: null,
      code: 200,
      message: 'release engine success',
    });
  },
  'POST /api/v1/engine/apply': (
    req: {
      body: {
        userId: string;
        engineName: string;
        cpus?: number;
        memory?: number;
        enableGpu?: boolean;
        engineImage: string;
      };
    },
    res: any,
  ) => {
    const {
      cpus,
      memory,
      enableGpu,
      userId,
      engineName,
      engineImage: image,
    } = req.body;
    let newData = {
      ...applyRes,
      cpus,
      memory,
      enableGpu,
      userId,
      engineName,
      image,
    };

    engines.push(newData);
    res.json({
      success: true,
      errorCode: 0,
      data: newData,
      code: 200,
      message: '获取引擎列表成功',
    });
  },
};
